<?php 

class Add_Setup_Account_Save_Validate_NewPassword extends Ext_Validate_Abstract
{
    protected $_password;
    protected $_confirmPassword;
    
    public function __construct($password, $confirmPassword)
    {
        $this->_password         = $password;
        $this->_confirmPassword  = $confirmPassword;
    }
    
    public function isValid()
    {
        $validator = new Zend_Validate_StringLength(6, 12);
        $validator->setObscureValue(1);
        $validatorChain = new Zend_Validate();
        $validatorChain
            ->addValidator(new Zend_Validate_NotEmpty(), true)
            ->addValidator($validator, true)
            ->addValidator(new Zend_Validate_Identical($this->_confirmPassword), true)
            ;
        
        if(!$validatorChain->isValid($this->_password)) {
            $this->addMessages('New password', $validatorChain->getMessages());
            return false;
        }
        
        return true;
    }
}
